package test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @Time 2020-10-30 02:00
 * @Email 44867924@qq.com
 * @Auth fan
 * @Version 1.0v
 */
public class Demo {
    public static void main(String[] args) {
        List<Person> list = new ArrayList<>();
       for(int i = 0;i<5;i++){
           Person p = new Person(i);
           list.add(p);
       }
        Person person = list.get(2);
        Person temp = new Person(20);
        person = temp;
        //person.age = temp.age;


        System.out.println(list);


    }

}

class Person{
    int age;

    public Person(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }
}
